package lp.xian.materials.service.impl;

import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import lp.xian.materials.vo.SaleoutVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.mapper.SaleoutMapper;
import com.ruoyi.common.domain.Saleout;
import lp.xian.materials.service.ISaleoutService;

/**
 * 销售出库Service业务层处理
 *
 * @author ruoyi
 * @date 2023-08-25
 */
@Service
public class SaleoutServiceImpl implements ISaleoutService
{
    @Autowired
    private SaleoutMapper saleoutMapper;

    /**
     * 查询销售出库
     *
     * @param saleoutId 销售出库主键
     * @return 销售出库
     */
    @Override
    public Saleout selectSaleoutBySaleoutId(Integer saleoutId)
    {
        return saleoutMapper.selectSaleoutBySaleoutId(saleoutId);
    }

    /**
     * 查询销售出库列表
     *
     * @param saleout 销售出库
     * @return 销售出库
     */
    @Override
    public List<Saleout> selectSaleoutList(Saleout saleout)
    {
        return saleoutMapper.selectSaleoutList(saleout);
    }

    /**
     * 新增销售出库
     *
     * @param saleout 销售出库
     * @return 结果
     */
    @Override
    public int insertSaleout(Saleout saleout)
    {
        saleout.setCreateTime(DateUtils.getNowDate());
        return saleoutMapper.insertSaleout(saleout);
    }

    /**
     * 修改销售出库
     *
     * @param saleout 销售出库
     * @return 结果
     */
    @Override
    public int updateSaleout(Saleout saleout)
    {
        saleout.setUpdateTime(DateUtils.getNowDate());
        return saleoutMapper.updateSaleout(saleout);
    }

    /**
     * 批量删除销售出库
     *
     * @param saleoutIds 需要删除的销售出库主键
     * @return 结果
     */
    @Override
    public int deleteSaleoutBySaleoutIds(Integer[] saleoutIds)
    {
        return saleoutMapper.deleteSaleoutBySaleoutIds(saleoutIds);
    }

    /**
     * 删除销售出库信息
     *
     * @param saleoutId 销售出库主键
     * @return 结果
     */
    @Override
    public int deleteSaleoutBySaleoutId(Integer saleoutId)
    {
        return saleoutMapper.deleteSaleoutBySaleoutId(saleoutId);
    }

    @Override
    public int auditSaleout(SaleoutVo saleoutVo) {
        Saleout saleout =new Saleout();
        saleout.setSaleoutId(saleoutVo.getSaleoutId());
        saleout.setAuditStatus(saleoutVo.getAuditStatus());
        saleout.setAuditOpinion(saleoutVo.getAuditOpinion());
        saleout.setAuditPerson(SecurityUtils.getUsername());
        saleout.setAuditTime(new Date());
        return saleoutMapper.updateSaleout(saleout);
    }
}
